//
//  BBYClientDataViewController.m
//  BearSiX
//
//  Created by Tom on 16/3/26.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBYClientDataViewController.h"
#import "BBYClientDataCell.h"
#import "BBYClickDetailViewController.h"
#import "BBProductCell.h"//产品资料cell
#import "BBDressCollecCell.h"//礼服资料cell
#import "BBYClientDataViewController.h"//礼服详情
#import "BBXFTypeViewController.h"
#import "BBYPhotoView.h"
//#import "BBYPhotoScroView.h"
@interface BBYClientDataViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,UICollectionViewDataSource,UICollectionViewDelegate>
{
    UIImageView *_statusImage;
    UIButton *deleteBtn;
    //客户资料
    UIButton *button;
    NSMutableArray *_textFirstArr;//
    NSArray *_dataFirstArr;
    NSArray *_dataSecArr;
    NSArray *_placehFirstArr;
    NSArray *_placeSecArr;
    NSMutableArray *_clientDataArr;
    //拍照资料
    UIView *_takePhotoView;
    BOOL _photoStatus;
    BOOL _buPaiStatus;
    //选片资料
    NSMutableArray *_chooseTextArr;
    NSMutableArray *_chooseDetailArr;
}
//客户资料
@property(nonatomic,strong)UITableView *clientTableView;
@property(nonatomic,strong)UITableView *tableView1;
@property(nonatomic,strong)UITableView *tableView2;
@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,strong)UIView *productView;//产品界面
@property(nonatomic,strong)UITableView *productTabliView;//产品资料
@property(nonatomic,strong)UIView *productControView;

@property(nonatomic,strong)UICollectionView *dressCollecView;//礼服资料

@property(nonatomic,strong)UITableView *tableViewPhoto;//拍照资料
@property(nonatomic,strong)UITableView *chooseTableView;//选片资料
@end

@implementation BBYClientDataViewController
//客户资料
-(UITableView *)clientTableView{

    if (!_clientTableView) {
        _clientTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, WINSIZEWIDTH, 0)];
        _clientTableView.delegate = self;
        _clientTableView.dataSource = self;
        _clientTableView.tableFooterView = [[UIView alloc]init];
        _clientTableView.backgroundColor = [UIColor colorWithHexString:@"a6a9a3" alpha:0.8];
    }
    return _clientTableView;
}
-(UIScrollView *)scrollView{

    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, WINSIZEWIDTH, self.view.height)];
        _scrollView.contentSize = CGSizeMake(WINSIZEWIDTH*2, WINSIZEHEIGHT);
        _scrollView.pagingEnabled = YES;
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        _scrollView.bounces = NO;
    }
    return _scrollView;
}

-(UITableView *)tableView1{

    if (!_tableView1) {
        _tableView1 = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, self.view.height)];
        _tableView1.delegate = self;
        _tableView1.dataSource = self;
        _tableView1.bounces = YES;
        UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEWIDTH)];
        BButton *nextBtn = [[BButton alloc]initWithFrame:CGRectMake(WINSIZEWIDTH/3, WINSIZEWIDTH/10, WINSIZEWIDTH/3, WINSIZEWIDTH/8) color:YDREDCOLOr style:(BButtonStyleBootstrapV2)];
        [nextBtn setTitle:@"下一页" forState:(UIControlStateNormal)];
        [nextBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        nextBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
        [footView addSubview:nextBtn];
        
        UISwipeGestureRecognizer *recognizer;
        
        recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(nextTableView:)];
        
        [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
        
      //  [[self view] addGestureRecognizer:recognizer];
        
        
        [nextBtn addTarget:self action:@selector(nextTableView:) forControlEvents:(UIControlEventTouchUpInside)];
        //_tableView1.tableFooterView = footView;
       // [_tableView1 addGestureRecognizer:recognizer];
    }
    return _tableView1;
}
-(UITableView *)tableView2{

    if(!_tableView2){
    
        _tableView2 = [[UITableView alloc]initWithFrame:CGRectMake(WINSIZEWIDTH, 64, WINSIZEWIDTH, self.view.height)];
        _tableView2.delegate = self;
        _tableView2.dataSource = self;
        _tableView2.bounces = YES;
        UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEWIDTH)];
        BButton *nextBtn = [[BButton alloc]initWithFrame:CGRectMake(WINSIZEWIDTH/3, WINSIZEWIDTH/10, WINSIZEWIDTH/3, WINSIZEWIDTH/8) color:YDREDCOLOr style:(BButtonStyleBootstrapV2)];
        [nextBtn setTitle:@"上一页" forState:(UIControlStateNormal)];
        [nextBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        nextBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
        [footView addSubview:nextBtn];
        [nextBtn addTarget:self action:@selector(agoTableView:) forControlEvents:(UIControlEventTouchUpInside)];
       // _tableView2.tableFooterView = footView;
        
        
        UISwipeGestureRecognizer *recognizer;
        
        recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(agoTableView:)];
        
        [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
        [_tableView2 addGestureRecognizer:recognizer];
    }
    return _tableView2;
}
#pragma mark -- viewDidLoad
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initData];
    self.view.backgroundColor = BACKCOLOR;
    [self.view addSubview:self.tableView1];
    //[self.view addSubview:self.tableView2];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:(UIBarButtonItemStyleDone) target:self action:@selector(editItme:)];
    button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH/3, self.navigationController.navigationBar.height)];
    _statusImage = [[UIImageView alloc]initWithFrame:CGRectMake(button.width-WINSIZEHEIGHT/27, 0, WINSIZEWIDTH/27, button.height)];
    _statusImage.image = [UIImage imageNamed:@"shouqi_y"];
    _statusImage.contentMode = UIViewContentModeScaleAspectFit;
    [button addSubview:_statusImage];
    [button setTitle:@"客户资料     " forState:(UIControlStateNormal)];
    [button setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    button.titleLabel.font = [UIFont systemFontOfSize:20];
    [button addTarget:self action:@selector(clientBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    button.centerX = WINSIZEWIDTH/2;
    [self.navigationController.navigationBar addSubview:button];

    [self.dressCollecView registerClass:[BBDressCollecCell class] forCellWithReuseIdentifier:@"dressCell"];

    [self initProductView];
    [self initDressView];
    
    [self createPhoteDataView];
    
    [self.view addSubview:self.chooseTableView];//选片资料
    //[self.view addSubview:self.dressCollecView];
    [self.view addSubview:self.clientTableView];

}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    button.alpha = 1;
    button.hidden = NO;
}
-(void)viewDidDisappear:(BOOL)animated{

    [super viewDidDisappear:animated];
    button.alpha = 0;
    button.hidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];
    [UIView animateWithDuration:0.1 animations:^{
        button.alpha = 0.3;
    }];
}
//客户资料
-(void)clientBtn:(UIButton *)sender{
    sender.selected = !sender.selected;

    if (sender.selected) {
        [UIView animateWithDuration:0.3 animations:^{
            self.clientTableView.height = self.view.height;
            _statusImage.image = [UIImage imageNamed:@"dakai_y"];
        }];
    }else{
        [UIView animateWithDuration:0.3 animations:^{
            self.clientTableView.height = 0;
            _statusImage.image = [UIImage imageNamed:@"shouqi_y"];

        }];
    }

}
-(void)editItme:(UIBarButtonItem *)sender{

}
#pragma mark -- scale tableview
-(void)nextTableView:(UISwipeGestureRecognizer *)sender{

    [UIView animateWithDuration:0.3 animations:^{
        self.tableView1.x=-WINSIZEWIDTH;
        self.tableView2.x = 0;
    } completion:^(BOOL finished) {
        [self.tableView1 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:(UITableViewScrollPositionTop) animated:YES];
    }];
}
-(void)agoTableView:(UISwipeGestureRecognizer *)sender{
    [UIView animateWithDuration:0.3 animations:^{
        self.tableView1.x=0;
        self.tableView2.x = WINSIZEWIDTH;
    } completion:^(BOOL finished) {
        [self.tableView2 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:(UITableViewScrollPositionTop) animated:YES];
    }];
}
#pragma mark -- tableview delegate

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    if (tableView==self.productTabliView) {
        return 10;
    }else if (tableView == self.tableViewPhoto){
        return 2;
    }else if (tableView==self.chooseTableView){
        return _chooseDetailArr.count;
    }
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    
    if (tableView == self.productTabliView) {
        return 1;
    }else if (tableView==self.chooseTableView){
        return ((NSArray *)_chooseTextArr[section]).count;
    }
    if (tableView==self.tableView1) {
        return _dataFirstArr.count;
    }else if(tableView==self.clientTableView){
        return _clientDataArr.count;
    }else if (tableView==self.tableViewPhoto){
        return 1;
    }
    return 0;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (tableView==self.tableViewPhoto) {
       return   WINSIZEWIDTH/5;
    }
    if (tableView==self.productTabliView) {
        if (indexPath.section==0) {
            return WINSIZEWIDTH/8;
        }else{
        
            return WINSIZEWIDTH/2.5;
        }
    }else{
        return WINSIZEWIDTH/6.7;
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *secitonHeadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEWIDTH/30)];
    secitonHeadView.backgroundColor = BACKCOLOR;
    return secitonHeadView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(tableView==self.tableViewPhoto){
        return WINSIZEWIDTH/50;
    }
    if (tableView==self.productTabliView) {
        return WINSIZEWIDTH/30;
    }
    if (tableView!=self.clientTableView) {
        return WINSIZEWIDTH/20;
    }else if (tableView==self.chooseTableView){
        return WINSIZEWIDTH/50;
    }
    return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (tableView==self.chooseTableView) {
        return WINSIZEWIDTH/50;
    }
    if(tableView==self.tableViewPhoto){
        if (_photoStatus&&section==0) {
            return WINSIZEWIDTH;
        }
        return WINSIZEWIDTH/30;
    }else{
        return 0;
    }
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (tableView==self.tableViewPhoto) {
        if (section==0&&_photoStatus) {
            BBYPhotoView *photoView = [[BBYPhotoView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, 100)];
            //photoView.contentSize = CGSizeMake(WINSIZEWIDTH, WINSIZEHEIGHT*2);
            
            [photoView createUI];
            photoView.layer.masksToBounds = YES;
            return photoView;
        }
    }
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEWIDTH/30)];
    headView.backgroundColor = BACKCOLOR;
    return headView;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *kongCell = nil;
    //客户资料第一页
    if (tableView==self.tableView1) {
        BBYClientDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        if (!cell) {
            cell = [[BBYClientDataCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell1"];
        }
        cell.detilField.text = @"";
        NSString *detilFieldText = [NSString stringWithFormat:@"%@",_textFirstArr[indexPath.row]];
        cell.typeLab.text = _dataFirstArr[indexPath.row];
        if ([NSString stringWithFormat:@"%@",_textFirstArr[indexPath.row]].length>1) {
            cell.detilField.text = detilFieldText;

        }else{
            cell.detilField.placeholder = _placehFirstArr[indexPath.row];
        }
        cell.detilField.delegate = self;
        cell.detilField.tag = 1000+indexPath.row;
        cell.detilField.returnKeyType = UIReturnKeyDone;

        if (indexPath.row==0||indexPath.row==4||indexPath.row==7||indexPath.row==8) {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detilField.enabled = NO;
        }else if(indexPath.row==2||indexPath.row==3){
            cell.detilField.enabled = NO;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }else{
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
        // 客户资料第二页
    }else if(tableView==self.tableView2){
        BBYClientDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        if (!cell) {
            cell = [[BBYClientDataCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell2"];
        }
        
        cell.typeLab.text = _dataSecArr[indexPath.row];
        cell.detilField.placeholder = _placeSecArr[indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.detilField.tag = 2000+indexPath.row;
        cell.detilField.delegate = self;
        cell.detilField.returnKeyType = UIReturnKeyDone;

        if (indexPath.row==0||indexPath.row==4) {
            cell.detilField.enabled = NO;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }else{
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
        //分类列表
    }else if(tableView==self.clientTableView){
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"clickCell"];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"clickCell"];
        }
        cell.textLabel.text = [NSString stringWithFormat:@"%@",_clientDataArr[indexPath.row]];
        return cell;
        //呵护资料
    }else if (tableView==self.productTabliView){
        if(indexPath.section==0){
            UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:nil];
            UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(WINSIZEWIDTH/20, 0, WINSIZEWIDTH-WINSIZEWIDTH/3, WINSIZEWIDTH/8)];
            titleLabel.text = @"包套：贺家弄幼儿园套餐D";
            titleLabel.textColor = [UIColor colorWithHexString:@"161616"];
            titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/21];
            
            UILabel *allRMB = [[UILabel alloc]initWithFrame:CGRectMake(WINSIZEWIDTH-WINSIZEWIDTH/3, 0, WINSIZEWIDTH/3-WINSIZEWIDTH/titleLabel.x, titleLabel.height)];
            allRMB.textColor = YDREDCOLOr;
            allRMB.textAlignment = NSTextAlignmentRight;
            allRMB.font = [UIFont systemFontOfSize:WINSIZEWIDTH/24];
            allRMB.text = @"￥1200";
            
            [cell.contentView addSubview:titleLabel];
            [cell.contentView addSubview:allRMB];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
        BBProductCell *productCell = [self.productTabliView dequeueReusableCellWithIdentifier:@"productCell"];
        if (!productCell) {
            productCell = [[BBProductCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"productCell"];
        }
        productCell.selectionStyle = UITableViewCellSelectionStyleNone;
        return productCell;
    //拍照资料
    }else if (tableView==self.tableViewPhoto){
        UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:nil];
        cell.textLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/24];
        cell.detailTextLabel.textColor = [UIColor colorWithHexString:@"656769"];
        cell.textLabel.text = @"拍照";
        cell.detailTextLabel.text = @"服务时间：2015-02-14";
        UIImageView *stausImage = [[UIImageView alloc]initWithFrame:CGRectMake(WINSIZEWIDTH-WINSIZEWIDTH/8, 0, WINSIZEWIDTH/17, cell.height)];
        stausImage.contentMode = UIViewContentModeScaleAspectFit;
        stausImage.image = [UIImage imageNamed:@"c_kai_y"];
        if (indexPath.section==0) {
            stausImage.image = _photoStatus?[UIImage imageNamed:@"c_guan_y"]:[UIImage imageNamed:@"c_kai_y"];
        }else if(indexPath.section==1){
        stausImage.image = _buPaiStatus?[UIImage imageNamed:@"c_guan_y"]:[UIImage imageNamed:@"c_kai_y"];
        }
        [cell.contentView addSubview:stausImage];
        return cell;
        //选片资料
    }else if (tableView==self.chooseTableView){
        UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:nil];
        cell.textLabel.text = _chooseTextArr[indexPath.section][indexPath.row];
        cell.detailTextLabel.text = _chooseDetailArr[indexPath.section][indexPath.row];
        cell.textLabel.textColor = [UIColor colorWithHexString:@"565759"];
        cell.textLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
        cell.detailTextLabel.textColor = [UIColor blackColor];
        cell.detailTextLabel.font = cell.textLabel.font;
        return cell;
    }
    return kongCell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if(tableView==self.clientTableView){
        button.selected = !button.selected;
    
        if (indexPath.row==0) {
            _takePhotoView.hidden = YES;
            self.tableView2.hidden = NO;
            self.tableView1.hidden = NO;
            self.dressCollecView.hidden=YES;
            self.productView.hidden = YES;
        }
        if (indexPath.row==1) {
            _takePhotoView.hidden = YES;

            self.tableView1.hidden = YES;
            self.tableView2.hidden = YES;
            self.productView.hidden = NO;
            self.dressCollecView.hidden = YES;
        }else if (indexPath.row==2){
            _takePhotoView.hidden = YES;

            self.tableView1.hidden = YES;
            self.tableView2.hidden = YES;
            self.productView.hidden = YES;
            self.dressCollecView.hidden = NO;
        }else if (indexPath.row==3){
        
            _takePhotoView.hidden = NO;
            
            self.tableView1.hidden = YES;
            self.tableView2.hidden = YES;
            self.productView.hidden = YES;
            self.dressCollecView.hidden = YES;
            
        }
        if (button.selected) {
            [UIView animateWithDuration:0.3 animations:^{
                self.clientTableView.height = self.view.height;
                _statusImage.image = [UIImage imageNamed:@"dakai_y"];

            }];
        }else{
            [UIView animateWithDuration:0.3 animations:^{
                self.clientTableView.height = 0;
                _statusImage.image = [UIImage imageNamed:@"shouqi_y"];

            }];
        }
        NSString *titleLabel = [NSString stringWithFormat:@"%@      ",_clientDataArr[indexPath.row]];
        [button setTitle:titleLabel forState:(UIControlStateNormal)];
    }else if (tableView==self.tableView1){
    
        [self.navigationController pushViewController:[BBXFTypeViewController new] animated:YES];
    }else if (tableView==self.tableViewPhoto){
        if (indexPath.section==0) {
            _photoStatus = _photoStatus?NO: YES;
            [self.tableViewPhoto reloadData];
        }else if (indexPath.section==1){
            _buPaiStatus = _buPaiStatus?NO:YES;
            [self.tableViewPhoto reloadData];
        }
    }
}
#pragma mark -- textfield deldgate

-(BOOL)textFieldShouldReturn:(UITextField *)textField{

    [self.view endEditing:YES];
    return YES;
}
-(void)textFieldDidBeginEditing:(UITextField *)textField{

    NSLog(@"textfildTag:%ld",textField.tag);
    if (textField.tag>=2000) {
        NSInteger row = textField.tag-2000;
        NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:0];
        [self.tableView2 scrollToRowAtIndexPath:index atScrollPosition:(UITableViewScrollPositionTop) animated:YES];
    }else{
    
        NSInteger row = textField.tag-1000;
        NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:0];
        [self.tableView1 scrollToRowAtIndexPath:index atScrollPosition:(UITableViewScrollPositionTop) animated:YES];
    }
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
    if (textField.tag>=2000) {
        NSInteger row = textField.tag-2000;
        NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:0];
        [self.tableView2 scrollToRowAtIndexPath:index atScrollPosition:(UITableViewScrollPositionMiddle) animated:YES];
    }else{
        
        NSInteger row = textField.tag-1000;
        NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:0];
        [self.tableView1 scrollToRowAtIndexPath:index atScrollPosition:(UITableViewScrollPositionMiddle) animated:YES];
    }
    
}
-(void)initData{

    _dataFirstArr = @[@"服务店面",@"客户编号",@"订单类型",@"预约日期",@"消费类别",@"男士姓名",@"女士姓名",@"客户来源",@"客户分区",@"门市接待",@"门 市 一",@"门 市 二",@"会员卡号",@"会员类型",@"男士手机",@"女士手机"];
   // NSLog(@"++++%@ %ld",_dataFirstArr,_dataFirstArr.count);
    
    _dataSecArr = @[@"门市接待",@"门 市 一",@"门 市 二",@"会员卡号",@"会员类型",@"男士手机",@"女士手机"];
    
    _placehFirstArr = @[@"",@"请输入客户编号",@"",@"",@"请选择类型",@"请输入男士姓名",@"请输入女士姓名",@"请选择客户来源",@"请选择客户分区",@"请选择接待人",@"请输入姓名",@"请输入姓名",@"请输入卡号",@"请选择会员类型",@"请输入男士手机",@"请输入女士手机",@"",@""];
    
    _placeSecArr = @[@"请选择接待人",@"请输入姓名",@"请输入姓名",@"请输入卡号",@"请选择会员类型",@"请输入男士手机",@"请输入女士手机",@"",@""];
    
    _textFirstArr = [@[@"北京施华洛婚纱摄影广渠门店",@"",@"婚纱照",@"2015年11月26日",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@""]mutableCopy];
    
    _clientDataArr = [@[@"客户资料",@"产品资料",@"礼服资料",@"拍照资料",@"选片资料",@"取片资料",@"排程资料"]mutableCopy];
    //选片资料
    _chooseTextArr = [@[@[@"查看照片（364张）"],
                       @[@"选 片 师",@"选片日期"],
                       @[@"选片通知",@"选片状态"],
                       @[@"拍片张数",@"已选张数",@"拍衣套数",@"入册套数",@"美编P图",@"设计P图",@"赠送张数"]]mutableCopy];
    _chooseDetailArr = [@[@[@""],
                          @[@"王萌萌",@"2015-02-18"],
                          @[@"已通知",@"已选完"],
                          @[@"320",@"0",@"20张",@"6套",@"150张",@"216张",@"10张"]]mutableCopy];
}
#pragma mark -- 产品资料
-(UIView *)productView{

    if (!_productView) {
        _productView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.width, self.view.height)];
        _productView.backgroundColor = BACKCOLOR;
    }
    return _productView;
}
-(UITableView *)productTabliView{

    if (!_productTabliView) {
        _productTabliView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.productView.width,self.productView.height)];
        _productTabliView.delegate = self;
        _productTabliView.dataSource = self;
        _productTabliView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _productTabliView;
}
-(UIView *)productControView{

    if (!_productControView) {
        _productControView = [[UIView alloc]initWithFrame:CGRectMake(0, self.view.height-WINSIZEWIDTH/6.5-64, WINSIZEWIDTH, WINSIZEWIDTH/6.5)];
        _productControView.backgroundColor = [UIColor whiteColor];
        
        UIView *vorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, 1.5)];
        vorView.backgroundColor = [UIColor colorWithHexString:@"ececec"];
        [_productControView addSubview:vorView];
        
        UIButton *allChooseBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH/3, _productControView.height)];
        [allChooseBtn setTitle:@"  全选" forState:(UIControlStateNormal)];
        [allChooseBtn setImage:[UIImage imageNamed:@"p_choose_y"] forState:(UIControlStateSelected)];
        [allChooseBtn setImage:[UIImage imageNamed:@"p_choose_n"] forState:(UIControlStateNormal)];
        [allChooseBtn addTarget:self action:@selector(chooseAll:) forControlEvents:(UIControlEventTouchUpInside)];
        allChooseBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/20];
        [allChooseBtn setTitleColor:[UIColor colorWithHexString:@"161616"] forState:(UIControlStateNormal)];
        
        deleteBtn = [[UIButton alloc]initWithFrame:CGRectMake(WINSIZEWIDTH-WINSIZEWIDTH/3.3-WINSIZEWIDTH/20, WINSIZEWIDTH/40, WINSIZEWIDTH/3.3, _productControView.height-WINSIZEWIDTH/20)];
        deleteBtn.layer.cornerRadius = WINSIZEWIDTH/80;
        deleteBtn.layer.masksToBounds = YES;
        [deleteBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        [deleteBtn setBackgroundColor:[UIColor colorWithHexString:@"a7a9ab"]];
        [deleteBtn setTitle:@"删除" forState:(UIControlStateNormal)];
        deleteBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/20];
        
        [_productControView addSubview:allChooseBtn];
        [_productControView addSubview:deleteBtn];
    }
    return _productControView;
}
#pragma mark -- 全选
-(void)chooseAll:(UIButton *)sender{

    sender.selected = !sender.selected;
    if (sender.selected) {
        [deleteBtn setBackgroundColor:YDREDCOLOr];
    }else{
    [deleteBtn setBackgroundColor:[UIColor colorWithHexString:@"a7a9ab"]];
    }
}
-(void)initProductView{

    [self.view addSubview:self.productView];
    [self.productView addSubview:self.productTabliView];
    [self.productView addSubview:self.productControView];
    self.productView.hidden = YES;
}
#pragma mark -- 礼服资料
-(UICollectionView *)dressCollecView{

    if (!_dressCollecView) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        [flowLayout setMinimumInteritemSpacing:WINSIZEWIDTH/35];
        [flowLayout setMinimumLineSpacing:WINSIZEWIDTH/30];
        [flowLayout setSectionInset:UIEdgeInsetsMake(WINSIZEWIDTH/30, WINSIZEWIDTH/30, WINSIZEWIDTH/20, WINSIZEWIDTH/30)];
        [flowLayout setItemSize:CGSizeMake((WINSIZEWIDTH-WINSIZEWIDTH/10)/2, WINSIZEWIDTH/1.36)];
        _dressCollecView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 64, WINSIZEWIDTH, self.view.height-64) collectionViewLayout:flowLayout];
        _dressCollecView.delegate = self;
        _dressCollecView.dataSource = self;
        _dressCollecView.backgroundColor = [UIColor whiteColor];

    }
    return _dressCollecView;
}
-(void)initDressView{

    
    [self.view addSubview:self.dressCollecView];
    self.dressCollecView.hidden = YES;
    
}
#pragma mark -- dress collection delegate
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 9;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    BBDressCollecCell *dressCell = (BBDressCollecCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"dressCell" forIndexPath:indexPath];
    
    
    return dressCell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    NSLog(@"+++collec%@",indexPath);

    if (indexPath.row==0) {
        BBYClickDetailViewController *clickDetailVC = [[BBYClickDetailViewController alloc]init];
        [self.navigationController pushViewController:clickDetailVC animated:YES];
    }
   
}
#pragma mark -- 拍照资料
-(void)createPhoteDataView{

    _photoStatus = NO;
    _buPaiStatus = NO;
    _takePhotoView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, WINSIZEWIDTH, self.view.height)];
    _takePhotoView.backgroundColor = BACKCOLOR;
    
    [_takePhotoView addSubview:self.tableViewPhoto];
    _takePhotoView.hidden = YES;
    [self.view addSubview:_takePhotoView];
}
-(UITableView *)tableViewPhoto{

    if (!_tableViewPhoto) {
        _tableViewPhoto = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, _takePhotoView.height)];
        _tableViewPhoto.bounces = NO;
        _tableViewPhoto.delegate = self;
        _tableViewPhoto.dataSource = self;
    }
    return _tableViewPhoto;
}
#pragma mark -- 选片资料
-(UITableView *)chooseTableView{

    if (!_chooseTableView) {
        _chooseTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, self.view.height)];
        _chooseTableView.delegate = self;
        _chooseTableView.dataSource = self;
    }
    return _chooseTableView;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
